<template>
	<view class="content">
		<web-view class="webviews" update-title="false" :src="urls" @message="getMessage"
			@onPostMessage="onpostmsg"></web-view>
		<!-- <image src="../../static/none.png" mode="widthFix" class="noneimg" v-if="shownull"></image> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				urls: '',
				id: '',
				objurl: '',
				action: "",
				shownull: false
			}
		},
		onLoad(e) {


		},
		onShow() {
			this.API_page();
			// uni.navigateTo({
			// 	url: '/pages/3d/back'
			// })
			// uni.navigateBack({
			// 	delta: 1
			// })
		},
		onShareAppMessage(e) {
			console.log('测试0', e)
		},
		methods: {
			testbrn() {
				conosle.log(this.$refs.webview)
			},
			onpostmsg: function(data) {
				console.log("接收到消息：", data);
			},
			getMessage(e) {
				console.log('1234测试', e)
				if (e.detail.data[0].objurl) {
					uni.setStorageSync('objurl', e.detail.data[0].objurl)
				}
				if (e.detail.data[0].model_id) {
					uni.setStorageSync('model_id', e.detail.data[0].model_id)
				}

			},
			ckimg(id) {
				uni.navigateTo({
					url: '/pages/public/webview?id=' + id
				})
			},
			API_page() {
				var that = this;
				that.ran
					.request('/app-api/model/user-space/page', {
						pageNo: 1,
						pageSize: 1,
						isAll: true
					}, 'POST')
					.then(res => {
						console.log(res);
						if (res.code == 200) {
							// if (res.data.list.length == 0) {
							// 	that.shownull = true;
							// } else {
							// 	that.id = res.data.list[0].id;
							// 	// that.urls = 'https://3d.28vu.com/?id=' + that.id + '&Authorization=' + uni
							// 	that.urls = 'https://test.huanti3d.com/?type=1&id=' + that.id + '&Authorization=' + uni
							// 		.getStorageSync('accessToken');
							// }

							if (res.data.list.length == 0) {
								that.id = 0;
							} else {
								that.id = res.data.list[0].id;
							}
							// that.urls = 'https://3d.28vu.com/?id=' + that.id + '&Authorization=' + uni
							that.urls = 'https://test.huanti3d.com/?type=1&id=' + that.id + '&Authorization=' + uni
								.getStorageSync('accessToken');
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
						}
					});
			},
		}
	}
</script>

<style lang="scss">
	.noneimg {
		width: 300rpx;
		margin: 100rpx auto;
		display: block;
	}
</style>